{include file="common/head"/}
<div class="admin-main layui-anim layui-anim-upbit" ng-app="hd" ng-controller="ctrl">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>{$title}</legend>
    </fieldset>
    <form class="layui-form layui-form-pane">
        <div class="layui-form-item">
            <label class="layui-form-label">主队</label>
            <div class="layui-input-4">
                <select name="home_id" lay-verify="required" ng-model="selected" ng-options="v.home_id as v.team_name for v in group track by v.home_id">
                    <option value="">请选择主队</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">客队</label>
            <div class="layui-input-4">
                <select name="guest_id" lay-verify="required" ng-model="selectedguest" ng-options="v.guest_id as v.team_name for v in group track by v.guest_id">
                    <option value="">请选择客队</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">比赛时间</label>
            <div class="layui-input-4">
                <input type="text" name="match_time" ng-model="field.match_time" lay-verify="required" placeholder="比赛时间" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-block">
                <input type="radio" name="status" ng-model="field.status" ng-checked="field.status == 0" ng-value="0" title="未开放">
                <input type="radio" name="status" ng-model="field.status" ng-checked="field.status == 1" ng-value="1" title="答题中">
                <input type="radio" name="status" ng-model="field.status" ng-checked="field.status == 2" ng-value="2" title="关闭">
                <input type="radio" name="status" ng-model="field.status" ng-checked="field.status == 3" ng-value="3" title="显示答案">
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="button" class="layui-btn" lay-submit="" lay-filter="submit">{:lang('submit')}</button>
                <a href="{:url('index')}" class="layui-btn layui-btn-primary">{:lang('back')}</a>
            </div>
        </div>
    </form>
</div>
{include file="common/foot"/}
<script src="__STATIC__/common/js/angular.min.js"></script>
<script>
                    var m = angular.module('hd', []);
                    m.controller('ctrl', ['$scope', function($scope) {
                    $scope.field = '{$info|raw}' != 'null'?{$info | raw}:{match_id:'',home_id:'', guest_id:'', match_time:'', status:0};
                    $scope.group = {$teamlist | raw};
                    $scope.selected = {$selected | raw};
                    
                    $scope.selectedguest = {$selectedguest | raw};
                    layui.use(['form', 'layer', 'upload'], function () {
                    var form = layui.form, $ = layui.jquery, upload = layui.upload;
                    if ($scope.field.pic){
                    adPic.src = $scope.field.pic;
                    }
                    form.on('submit(submit)', function (data) {
                    // 提交到方法 默认为本身
                    data.field.match_id = $scope.field.match_id;
                    var loading = layer.load(1, {shade: [0.1, '#fff']});
                    $.post("", data.field, function (res) {
                    layer.close(loading);
                    if (res.code > 0) {
                    layer.msg(res.msg, {time: 1800, icon: 1}, function () {
                    location.href = res.url;
                    });
                    } else {
                    layer.msg(res.msg, {time: 1800, icon: 2});
                    }
                    });
                    });
                 
                    });
                    }]);
</script>